﻿//Write a program to convert decimal numbers to their binary representation.

using System;
using System.Collections.Generic;
class DecimalToBinary
{
    static void Main()
    {
        Console.WriteLine("Please, enter a number");
        int number = int.Parse(Console.ReadLine());

        List<int> binary = ToBinary(number);

        Console.WriteLine("Binary representation: ");
        for (int i = 0; i < binary.Count; i++) //Print the list
        {
            Console.Write(binary[i]);
        }

        Console.WriteLine();

    }

    static List<int> ToBinary(int number) //Binary representation method, using the algorithm for decimal to binary convertion
    {
        int reminder;
        int temp = number;
        List<int> result = new List<int>();

        do
        {
            reminder = temp % 2;
            temp = temp / 2;
            result.Add(reminder);
        }
        while (temp > 0);

        result.Reverse();

        return result;
    }
}
